package com.design.builder.sql;

/**
 * sql排序组件
 * @author:         cong zhi
 * @createDate:     2022/5/8 23:22
 * @updateUser:     cong zhi
 * @updateDate:     2022/5/8 23:22
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
public class Order {
    /**
     * 升序或降序
     */
    private Boolean ascending;
    /**
     * 字段升序，那个字段降序
     */
    private String propertyName;

    @Override
    public String toString() {
        return propertyName + ' ' + (ascending ? "asc" : "desc");
    }

    public Order(Boolean ascending, String propertyName) {
        this.ascending = ascending;
        this.propertyName = propertyName;
    }

    public static Order asc(String propertyName) {
        return new Order(true, propertyName);
    }

    public static Order desc(String propertyName) {
        return new Order(true, propertyName);
    }
}
